package com.shmn.gongjiajumain.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.ArrayList;

@Configuration
public class SwaggerConfig {

    @Value("${spring.profiles.active}")
    private String environment;

    //配置Swagger的Docket的bean实例
    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
//                .enable(environment.equals("dev"))
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.shmn.gongjiajumain.controller"))
//                .paths(PathSelectors.ant("/demo/**"))
                .build();
    }
    //配置Swagger的主页信息
    public ApiInfo apiInfo() {

        //作者信息
        Contact contact = new Contact("夏尹航", "", "1005074582@qq.com");

        return new ApiInfo("工夹具的Swagger文档",
                "三好码农队",
                "1.0",
                "urn:tos",
                contact,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList());
    }


}
